use actix_web::{Responder, get, web};

use crate::learn::learn_enum::{Coin, UsState, describe_state_quarter, value_in_cents};

#[get("/")]
async fn hello() -> impl Responder {
    "Hello, world!"
}

#[get("/try_enum")]
async fn try_enum() -> impl Responder {
    let coin = Coin::Quarter(UsState::Alabama);
    web::Json(serde_json::json!({
        "coin": format!("{:?}", &coin),
        "value_in_cents": value_in_cents(&coin),
        "describe_state_quarter": format!("{:?}", describe_state_quarter(&coin)),
        "describe_state_for_dime": format!("{:?}", describe_state_quarter(&Coin::Dime)),
    }))
}
